package com.senac.service;

import java.util.List;

import com.senac.dao.ProfessorDao;
import com.senac.exception.ProfessorException;
import com.senac.model.Professor;

public class ProfessorService implements ProfessorServiceLocal {
	
	private ProfessorDao dao = new ProfessorDao();

	@Override
	public List<Professor> get() {
		return dao.getProfessores();
	}

	@Override
	public Professor getById(Integer id) {
		return dao.getProfessorById(id);
	}

	@Override
	public boolean save(Professor professor) throws ProfessorException {
		
		ProfessorValidate.validateProfessor(professor);
		
		if(professor.getId() > 0) {
			return update(professor);
		} else {
			return insert(professor);
		}
	}

	@Override
	public boolean insert(Professor professor) {
		return dao.save(professor);	
	}

	@Override
	public boolean update(Professor professor) {
		return dao.update(professor);
	}

	@Override
	public boolean delete(Integer id) {
		return dao.delete(id);
	}

	@Override
	public boolean verifyNome(String username, int id) {
		return dao.verifyUsername(username, id);
	}
	
	
	public int getCargaHorariaTotal(int idProfessor, int idDisciplina) {
		return dao.getCargaHorariaTotal(idProfessor, idDisciplina);
	}
	
}
